package yur.wedding.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import yur.wedding.modules.sys.entity.SysProcessRequestbaseEntity;
import yur.wedding.modules.sys.service.SysProcessRequestbaseService;

import yur.wedding.utils.PageUtils;
import yur.wedding.utils.R;
import yur.wedding.validator.ValidatorUtils;


/**
 *
 *   流程信息管理
 * @author Yur
 * @email ${email}
 * @date 2022-05-02 22:54:50
 */
@RestController
@RequestMapping("sys/sysprocessrequestbase")
public class SysProcessRequestbaseController {
    @Autowired
    private SysProcessRequestbaseService sysProcessRequestbaseService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:sysprocessrequestbase:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysProcessRequestbaseService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{requestid}")
    @RequiresPermissions("sys:sysprocessrequestbase:info")
    public R info(@PathVariable("requestid") Integer requestid){
        SysProcessRequestbaseEntity sysProcessRequestbase = sysProcessRequestbaseService.getById(requestid);

        return R.ok().put("sysProcessRequestbase", sysProcessRequestbase);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:sysprocessrequestbase:save")
    public R save(@RequestBody SysProcessRequestbaseEntity sysProcessRequestbase){
        sysProcessRequestbaseService.save(sysProcessRequestbase);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:sysprocessrequestbase:update")
    public R update(@RequestBody SysProcessRequestbaseEntity sysProcessRequestbase){
        ValidatorUtils.validateEntity(sysProcessRequestbase);
        sysProcessRequestbaseService.updateById(sysProcessRequestbase);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:sysprocessrequestbase:delete")
    public R delete(@RequestBody Integer[] requestids){
        sysProcessRequestbaseService.removeByIds(Arrays.asList(requestids));

        return R.ok();
    }

}
